﻿/*
 * ============ [ 废土 ] ============
 *
 * [ 维护者 ]  argoran@gmail.com
 * [  状态  ]  原型
 *
 * ============ [ 注释 ] ============
 *
 * 服务器端程序消息处理代码
 *
 * ==================================
 */

using LastLand.Core.MsgProcessor;
using LastLand.Data.Global;

using Up2Link.SegString;
using Up2Link.Server;

namespace LastLand.Core
{
    public class CMessage
    {
        private IMessageProcessor msgProc_;

        public void ProcessMessage(CMessagePack<CMessageSS> _msgPack)
        {
            CMessageSS msg = _msgPack.message;

            switch (msg.MsgCode)
            {
                case CConst.CLIENT_MESSAGE_NEW_ACCOUNT:
                    msgProc_ = new CMsgNewAccount();
                    break;
                case CConst.CLIENT_MESSAGE_CREATE_NORMAL:
                    msgProc_ = new CMsgCreateNormal();
                    break;
                case CConst.CLIENT_MESSAGE_CREATE_LEADER:
                    msgProc_ = new CMsgCreateLeader();
                    break;
                case CConst.CLIENT_MESSAGE_PLAY:
                    msgProc_ = new CMsgPlay();
                    break;
                case CConst.CLIENT_MESSAGE_LOGIN:
                    msgProc_ = new CMsgLogin();
                    break;
                case CConst.CLIENT_MESSAGE_LOGOUT:
                    msgProc_ = new CMsgLogout();
                    break;
                case CConst.CLIENT_MESSAGE_MOVE_EAST:
                    msgProc_ = new CMsgMoveEast();
                    break;
                case CConst.CLIENT_MESSAGE_MOVE_SOUTH:
                    msgProc_ = new CMsgMoveSouth();
                    break;
                case CConst.CLIENT_MESSAGE_MOVE_WEST:
                    msgProc_ = new CMsgMoveWest();
                    break;
                case CConst.CLIENT_MESSAGE_MOVE_NORTH:
                    msgProc_ = new CMsgMoveNorth();
                    break;
                case CConst.CLIENT_MESSAGE_TALK:
                    msgProc_ = new CMsgTalk();
                    break;
                case CConst.CLIENT_MESSAGE_COLLECT:
                    msgProc_ = new CMsgCollect();
                    break;
                case CConst.CLIENT_MESSAGE_BUILD_FARM:
                    msgProc_ = new CMsgBuildFarm();
                    break;
                case CConst.CLIENT_MESSAGE_BUILD_MINE:
                    msgProc_ = new CMsgBuildMine();
                    break;
                case CConst.CLIENT_MESSAGE_BUILD_VILLAGE:
                    msgProc_ = new CMsgBuildVillage();
                    break;
                case CConst.CLIENT_MESSAGE_BUILD_FORT:
                    msgProc_ = new CMsgBuildFort();
                    break;
                case CConst.CLIENT_MESSAGE_BUILD_CITY:
                    msgProc_ = new CMsgBuildCity();
                    break;
                case CConst.CLIENT_MESSAGE_BUILD_GRANARY:
                    msgProc_ = new CMsgBuildGranary();
                    break;
                case CConst.CLIENT_MESSAGE_BUILD_FORGE:
                    msgProc_ = new CMsgBuildForge();
                    break;
                case CConst.CLIENT_MESSAGE_BUILD_MARKET:
                    msgProc_ = new CMsgBuildMarket();
                    break;
                case CConst.CLIENT_MESSAGE_BUILD_COURTHOUSE:
                    msgProc_ = new CMsgBuildCourthouse();
                    break;
                case CConst.CLIENT_MESSAGE_BUY_MELEE:
                    msgProc_ = new CMsgBuyMelee();
                    break;
                case CConst.CLIENT_MESSAGE_BUY_RANGED:
                    msgProc_ = new CMsgBuyRanged();
                    break;
                case CConst.CLIENT_MESSAGE_BUY_SIEGE:
                    msgProc_ = new CMsgBuySiege();
                    break;
                case CConst.CLIENT_MESSAGE_BUY_HORSE:
                    msgProc_ = new CMsgBuyHorse();
                    break;
                case CConst.CLIENT_MESSAGE_BUY_ARMOR:
                    msgProc_ = new CMsgBuyArmor();
                    break;
                case CConst.CLIENT_MESSAGE_BUY_SHIELD:
                    msgProc_ = new CMsgBuyShield();
                    break;
                case CConst.CLIENT_MESSAGE_BUY_TMELEE:
                    msgProc_ = new CMsgBuyTMelee();
                    break;
                case CConst.CLIENT_MESSAGE_BUY_TRANGED:
                    msgProc_ = new CMsgBuyTRanged();
                    break;
                case CConst.CLIENT_MESSAGE_BUY_TSIEGE:
                    msgProc_ = new CMsgBuyTSiege();
                    break;
                case CConst.CLIENT_MESSAGE_BUY_TMOUNTED:
                    msgProc_ = new CMsgBuyTMounted();
                    break;
                case CConst.CLIENT_MESSAGE_BUY_TAGRICULTURE:
                    msgProc_ = new CMsgBuyTAgriculture();
                    break;
                case CConst.CLIENT_MESSAGE_BUY_TINDUSTRY:
                    msgProc_ = new CMsgBuyTIndustry();
                    break;
                case CConst.CLIENT_MESSAGE_BUY_TCOMMERCE:
                    msgProc_ = new CMsgBuyTCommerce();
                    break;
                case CConst.CLIENT_MESSAGE_BUY_TCONSTRUCTION:
                    msgProc_ = new CMsgBuyTConstruction();
                    break;
                case CConst.CLIENT_MESSAGE_ATTACK:
                    msgProc_ = new CMsgAttack();
                    break;
                case CConst.CLIENT_MESSAGE_DEFEND:
                    msgProc_ = new CMsgDefend();
                    break;
                case CConst.CLIENT_MESSAGE_RETREAT:
                    msgProc_ = new CMsgRetreat();
                    break;
                case CConst.CLIENT_MESSAGE_INFO_SERVER:
                    msgProc_ = new CMsgInfoServer();
                    break;
                case CConst.CLIENT_MESSAGE_INFO_ACCOUNT:
                    msgProc_ = new CMsgInfoAccount();
                    break;
                case CConst.CLIENT_MESSAGE_INFO_WORLD:
                    msgProc_ = new CMsgInfoWorld();
                    break;
                case CConst.CLIENT_MESSAGE_INFO_CHARACTER:
                    msgProc_ = new CMsgInfoCharacter();
                    break;
                case CConst.CLIENT_MESSAGE_INFO_GRID:
                    msgProc_ = new CMsgInfoGrid();
                    break;
                case CConst.CLIENT_MESSAGE_INFO_CITY:
                    msgProc_ = new CMsgInfoCity();
                    break;
                case CConst.CLIENT_MESSAGE_INFO_COUNTRY:
                    msgProc_ = new CMsgInfoCountry();
                    break;
                case CConst.CLIENT_MESSAGE_INFO_COMBAT:
                    msgProc_ = new CMsgInfoCombat();
                    break;
                default:
                    msgProc_ = new CMsgDefault();
                    break;
            }
            msgProc_.ProcessMessage(_msgPack);
        }
    }
}
